package com.wsd.music.service.imp;

import com.wsd.music.entity.Singer;
import com.wsd.music.mapper.SingerMapper;
import com.wsd.music.service.SingerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SingerServiceImp implements SingerService {

    @Resource
    private SingerMapper mapper;

    /**
     * 新增歌手
     *
     * @param singer
     * @return
     */
    @Override
    public boolean insert(Singer singer) {
        return mapper.insert(singer) > 0;
    }

    /**
     * 修改歌手信息
     *
     * @param singer
     * @return
     */
    @Override
    public boolean modify(Singer singer) {
        return mapper.modify(singer) > 0;
    }

    /**
     * 通过ID删除歌手
     *
     * @param id
     * @return
     */
    @Override
    public boolean delete(int id) {
        return mapper.delete(id) > 0;
    }

    /**
     * 通过主键ID查询歌手信息
     *
     * @param id
     * @return
     */
    @Override
    public Singer selectById(int id) {
        return mapper.selectById(id);
    }

    /**
     * 查询所有歌手
     *
     * @return
     */
    @Override
    public List<Singer> selectAll() {
        return mapper.selectAll();
    }

    /**
     * 通过歌手名进行模糊查询
     *
     * @param name
     * @return
     */
    @Override
    public List<Singer> selectSingerByName(String name) {
        return mapper.selectSingerByName(name);
    }

    /**
     * 通过性别查询歌手
     *
     * @param sex
     * @return
     */
    @Override
    public List<Singer> selectBySex(boolean sex) {
        return mapper.selectBySex(sex);
    }
}
